//
//  myview.m
//  myview
//
//  Created by sk on 11-7-25.
//  Copyright 2011 sk. All rights reserved.
//

#import "ForWardingView.h"

@implementation ForWardingView


- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        rrect.origin.x = 0;
        rrect.origin.y = 10;
        rrect.size.width = frame.size.width;
        rrect.size.height = frame.size.height-10;
    }
    

    return self;
}




-(void)drawInContext:(CGContextRef)context
{
	CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
	// And draw with a blue fill color
	CGContextSetRGBFillColor(context, 0.937, 0.949, 0.969, 1.0);
	// Draw them with a 2.0 stroke width so they are a bit more visible.
	CGContextSetLineWidth(context, 2.0);
//	CGContextSetShadow(context,CGSizeMake(-5.0, -5.0),1/3);
	CGContextSetShadowWithColor(context,CGSizeMake(0.0, 5.0),1/3,[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.8].CGColor);
	CGFloat radius = 10.0;
	CGFloat minx = CGRectGetMinX(rrect), midx = CGRectGetMidX(rrect), maxx = CGRectGetMaxX(rrect);
	CGFloat miny = CGRectGetMinY(rrect), midy = CGRectGetMidY(rrect), maxy = CGRectGetMaxY(rrect);
    NSLog(@"%f",maxy);

// Start at 1
    CGContextMoveToPoint(context, minx+20,miny);
    CGContextAddLineToPoint(context, minx+30, miny-10);
    CGContextAddLineToPoint(context, minx+40, miny);
    
    CGContextMoveToPoint(context, minx, midy);
    
	// Add an arc through 2 to 3
	CGContextAddArcToPoint(context, minx, miny, midx, miny, radius);
	// Add an arc through 4 to 5
	CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius);
	// Add an arc through 6 to 7
	CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);
	// Add an arc through 8 to 9
	CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius);
	// Close the path
	CGContextClosePath(context);
	// Fill & stroke the path
	//CGContextDrawPath(context, kCGPathFillStroke);
	//CGContextStrokePath(context);
	CGContextClip(context);
	CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
	CGFloat colors[] =
	{
		191.0 / 255.0, 239.0 / 255.0, 255.0 / 255.0, 1.0,
		191.0 / 255.0, 239.0 / 255.0, 255.0 / 255.0, 1.0,
		191.0 / 255.0, 239.0 / 255.0, 255.0 / 255.0, 1.0,
	};
	CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
	CGColorSpaceRelease(rgb);	
	CGContextDrawLinearGradient(context, gradient,CGPointMake(0.0,0.0) ,CGPointMake(0.0,self.frame.size.height), kCGGradientDrawsBeforeStartLocation);
	
	
	CGContextFillPath(context);
    
   
	
    
    
}




- (void)drawRect:(CGRect)rect
{
    
	[self drawInContext:UIGraphicsGetCurrentContext()];
}

@end
